﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Administration.Master" AutoEventWireup="true"
    CodeBehind="LogInfoCommon.aspx.cs" Inherits="ASB.CC.Web.Admin.LogInfoCommon" %>

<%@ Register Src="../UserControls/Pager.ascx" TagName="Pager" TagPrefix="cc" %>
<asp:Content ContentPlaceHolderID="Header" runat="server">

    <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script src="../js/jquery-ui.min.js" type="text/javascript"></script>

    <script src="../js/entity.js.aspx" type="text/javascript"></script>

    <style type="text/css">
        .description_row
        {
            overflow: hidden;
            width: 450px;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>

    <script type="text/javascript">
        $(function() {

            $(".datepicker").datepicker({
                changeYear: true,
                changeMonth: true,
                yearRange: 'c-40:c+10',
                changeYear: true,
                showOn: "button",
                buttonImage: "../../images/calendar.gif",
                buttonImageOnly: true,
                buttonText: 'Open Calendar (打开日历)'
            }).attr("readonly", "true");

            $(".date-cmp").bind("change", function() {

                var targetclass;
                var targetflag;
                var classes = $(this).attr('class').split(' ');
                for (i = 0; i < classes.length; i++) {
                    if (classes[i].indexOf('date-min') == 0) {
                        targetclass = 'date-max' + classes[i].substring(8, classes[i].length);
                        targetflag = 'max';
                        break;
                    }
                    else if (classes[i].indexOf('date-max') == 0) {
                        targetclass = 'date-min' + classes[i].substring(8, classes[i].length);
                        targetflag = 'min';
                        break;
                    }
                }

                if (targetclass != null) {
                    var target = $(".date-cmp." + targetclass).first();
                    var targetvalue = target.val();
                    if (targetvalue != '') {
                        if (targetflag == 'max') {
                            if (targetvalue.valueOf() < $(this).val().valueOf()) {
                                var mintitle = $(this).parent().prev().text();
                                var maxtitle = target.parent().prev().text();
                                alert('[' + mintitle + ']' + ' could not be later than ' + '[' + maxtitle + ']');
                                $(this).val('');
                            }
                        }
                        else //for targetflag == 'min'
                        {
                            if (targetvalue.valueOf() > $(this).val().valueOf()) {
                                var maxtitle = $(this).parent().prev().text();
                                var mintitle = target.parent().prev().text();
                                alert('[' + maxtitle + ']' + ' could not be earlier than ' + '[' + mintitle + ']');
                                $(this).val('');
                            }
                        }
                    }
                }
            });

        });
    </script>

</asp:Content>
<asp:Content ContentPlaceHolderID="Sitemap" runat="server">
    &nbsp;&raquo;&nbsp;Administration&nbsp;&raquo;&nbsp;Operation Log (<%=GetModuleName()%>)
</asp:Content>
<asp:Content ContentPlaceHolderID="Tab" runat="server">
    <%=Resources.PageTitles.OperationLog%>
    (<%=GetModuleName()%>)
</asp:Content>
<asp:Content ContentPlaceHolderID="Utility" runat="server">
    <asp:Panel ID="gridPanel" runat="server" CssClass="formbox_float_lft">
        <div>
            <span class=" float_lft">StartTime (开始时间):</span><span class=" float_lft padding_lft20">
                <input name="Log_StartTime" readonly="true" class="txtbox datepicker date-cmp date-min1"
                    value="<%#Eval("StartTime", "{0:d}") %>" /></span></div>
        <div>
            <span class="float_lft padding_lft20">EndTime (结束时间):</span><span class=" float_lft padding_lft20">
                <input name="Log_EndTIme" readonly="true" class="txtbox datepicker date-cmp date-max1"
                    value="<%#Eval("EndTime", "{0:d}") %>" /></span></div>
        <br />
        <br />
    </asp:Panel>
    <div class="formbox_float_lft">
        <asp:Button ID="btnAdd" runat="server" CssClass="entity-add" Style="display: none" />
    </div>
    <div class="formbox_float_rgt">
        <asp:TextBox ID="txtSearch" runat="server" CssClass="txtbox width140 entity-search-text"
            ToolTip="Description"></asp:TextBox>
        <asp:Button ID="btnSearch" runat="server" CssClass="entity-search" />
        <asp:Button ID="btnClear" runat="server" CssClass="entity-clear" />
    </div>
</asp:Content>
<asp:Content ContentPlaceHolderID="Main" runat="server">
    <asp:GridView ID="gvLog" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
        DataSourceID="edsLog" AllowPaging="True" EmptyDataText="There is no data to display!"
        CssClass="tablestyle" AllowSorting="True">
        <RowStyle CssClass="tbody" />
        <HeaderStyle CssClass="thead" ForeColor="#ffffff" />
        <Columns>
            <asp:TemplateField HeaderText="Description<br/>操作描述" SortExpression="Description">
                <ItemTemplate>
                    <div class="description_row">
                        <%#HttpUtility.HtmlEncode((string)Eval("Description"))%></div>
                </ItemTemplate>
                <ItemStyle Width="50%" />
            </asp:TemplateField>
            <%--  <asp:BoundField DataField="Module" HeaderText="Module<br/>模块名称" SortExpression="Module"
                HtmlEncode="false" ItemStyle-Width="6%" />--%>
            <asp:TemplateField HeaderText="CIL<br/>操作人" SortExpression="Employee.EmployeeNo">
                <ItemTemplate>
                    <asp:Label ID="Employee" runat="server" Text='<%#Eval("Employee.NameCN")%>' />
                </ItemTemplate>
                <ItemStyle Width="10%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Title<br/>职位" SortExpression="Employee.EmployeeNo">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("Employee.Title")%>' />
                </ItemTemplate>
                <ItemStyle Width="23%" />
            </asp:TemplateField>
            <asp:BoundField DataField="Time" HeaderText="Time<br/>操作时间" SortExpression="Time"
                HtmlEncode="false" ItemStyle-Width="12%" />
            <asp:ActionField HeaderText="Action<br/>操作" ShowViewButton="true" ItemStyle-Width="6%" />
        </Columns>
        <PagerTemplate>
            <cc:Pager runat="server" />
        </PagerTemplate>
    </asp:GridView>
    <asp:DetailsView ID="dvLog" runat="server" AutoGenerateRows="False" DataKeyNames="ID"
        DataSourceID="edsLog" Visible="False" CssClass="tablestyle2" Width="90%">
        <HeaderStyle CssClass="tablestyle2_Title"></HeaderStyle>
        <HeaderTemplate>
            <%=Resources.PageTitles.OperationLog%>
            (<%=GetModuleName()%>)
        </HeaderTemplate>
        <FieldHeaderStyle CssClass="tablestyle2_tdTitle" />
        <Fields>
            <asp:TemplateField HeaderText="CIL (操作人)">
                <ItemTemplate>
                    <asp:Label ID="Employee" runat="server" Text='<%#Eval("Employee.NameEN")%>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Title (职位)">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("Employee.Title")%>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Module" HeaderText="Module (模块名称)" SortExpression="Module"
                HtmlEncode="false" />
            <asp:BoundField DataField="Time" HeaderText="Time (操作时间)" HtmlEncode="false" SortExpression="Time" />
            <asp:BoundField DataField="Description" HeaderText="Description (操作描述)" SortExpression="Description" />
            <asp:ActionField ShowCloseButton="true" />
        </Fields>
    </asp:DetailsView>
    <%--以下是数据源--%>
    <asp:EntityDataSource ID="edsLog" runat="server" ConnectionString="name=CCEntities"
        DefaultContainerName="CCEntities" EntitySetName="OperationLog" Where="it.Module=@sys"
        Include="Employee" OrderBy="it.ID DESC">
        <WhereParameters>
            <asp:QueryStringParameter Name="sys" QueryStringField="sys" Type="String" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
